package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.dto.RiderPageQueryDTO;
import com.sky.dto.RiderUpdateInfoDTO;
import com.sky.entity.Employee;
import com.sky.entity.Orders;
import com.sky.entity.Rider;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RiderMapper {

    @Insert("insert into rider ( username, phone, sex, id_number, status, create_time, update_time, create_user, update_user) " +
            "VALUES " +
            "(#{username},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void add(Rider rider);
    Page<Rider> pageall(RiderPageQueryDTO riderPageQueryDTO);

    @AutoFill(value = OperationType.UPDATE)
    void update(Rider rider);
    @Select("select * from rider where id = #{id}")
    Rider getbyid(Integer id);
    @Select("select * from rider where phone = #{phone}")
    Rider getbyphone(String phone);
    @Select("select sum(deliveryfee) from orders where courierid = #{courierid}")
    Double getbalance(String courierid );


    @Select("select * from orders where courierid = #{courierid} order by delivery_time desc")
    List<Orders> getallorders(String courierid);
    @Select("select * from rider where openid = #{openid}")
    Rider getriderbyopenid(String openid);
    @AutoFill(value = OperationType.UPDATE)
    void updatebyphone(Rider rider);
    @AutoFill(value = OperationType.UPDATE)
    void updatebyopenid(Rider rider);
}
